home *** CD-ROM | disk | FTP | other *** search
/ MACup: Giveaway 1996 / Image.iso / Shareware & Demos / Web-Publishing / SNAP PrimeBase / WebDAL / About WebDAL next >
Encoding:
Text File  |  1996-07-30  |  12.2 KB  |  253 lines  |  [TEXT/ttxt]

  1. Using WebDAL™
  2.  
  3. You may write your own applications using WebDAL. To do this, you need to know how to write both HTML and DAL.
  4.  
  5. If you have an WYSWYG HTML editor then you don't have to know much about HTML (depending on how good the editor is). The editor must either support HTML comments, or extensions to HTML (custom TAGs) to be used in conjunction with WebDAL.
  6.  
  7. If you are familiar with SQL, then you are already know most of DAL, because DAL is a language based on SQL. DAL extends SQL to include cursors and other variables, common programming language constructs (if, while, switch, ...) and procedure and function definitions.
  8.  
  9.  
  10. Intranets
  11.  
  12. WebDAL is ideal for implementing intranet solutions. Database information can accessed, and returned to the user. Updates to the database are just as easy. You can use DAL to implement intelligent sites, that do more than just return information to the user. Input can be checked and even modified before the database is updated.
  13.  
  14.  
  15. How does it WebDAL work?
  16.  
  17. An important concept in DAL is idea of returning data to the application by "printing" the data. All data returned to the application must be "printed". Printed values (items) are place in an output stream, which is read by the application. There are various print statements: PRINTALL, PRINTROW, PRINTF and PRINT. By default, printed values are returned to the application  in text form.
  18.  
  19. The way WebDAL works is quite simple: WebDAL executes embedded DAL and then replaces the DAL program in the HTML page with the values from the output stream.
  20.  
  21. In particular this works as follows:
  22.  
  23. • DAL is embedded in the normal HTML page using the special tags <DAL> and </DAL> or inside a comment beginning with <!--DAL and ending with -->.
  24.  
  25. • When the page is requested WebDAL scans the page and executes each embedded DAL sub-program in the page in the order they appear.
  26.  
  27. • WebDAL replaces the DAL sub-programs with the values printed by the DAL sub-programs. In other words: an embedded DAL sub-program becomes its output!
  28.  
  29. For example:
  30.  
  31. <HTML>
  32.     <HEAD>
  33.         <TITLE>Greetings from DAL</TITLE>
  34.     </HEAD>
  35.     <BODY>
  36.     <--DAL print "Hello World!"; -->
  37.     </BODY>
  38. </HTML>
  39.  
  40. Becomes:
  41.  
  42. <HTML>
  43.     <HEAD>
  44.         <TITLE>Greetings from DAL</TITLE>
  45.     </HEAD>
  46.     <BODY>
  47.     Hello World!
  48.     </BODY>
  49. </HTML>
  50.  
  51. The DAL program which prints 'Hello World!' becomes 'Hello World!' in the HTML page.
  52.  
  53. The effect is extremely powerful. You may generate HTML using DAL, or just print values into an already completed page.
  54.  
  55. Pictures and other multi-media objects stored in the database are handled in the same way. You just have to select them, and print them. WebDAL takes care of placing such binary values in a temporary file (note the demo version of WebDAL on this CD cannot handle binary data).
  56.  
  57.  
  58. Browser Sessions
  59.  
  60. WebDAL takes the concept of a DAL session and extends it into the Web. This allows developers to create WebDAL based sites which interact with the user, storing information about what the users does, and reacting intelligently. This is done by establishing a virtual connection between the DAL session and the Web Browser.
  61.  
  62. A DAL session is an entity created by the DAL sub-system. All DAL programs execute within a particular session. An application may open multiple DAL sessions. Sessions are independent of one another, each having its own global variable space. Global variables and procedures declared in a session are available to all sub-programs that run in the session.
  63.  
  64. So, for example: by storing  a list in the session, the example application provided on this CD, knows which telephone numbers you have added in your session, and only allows you to delete these numbers.
  65.  
  66.  
  67. Session Timeout
  68.  
  69. The only problem with the session concept is that, on the Web, there is no concept of 'signing off' (or logging out). As a result WebDAL can never be sure when the user is finished. The only solution is to allow a session to "timeout" after a certain period of inactivity. This timeout value is configurable. Double-click on the 'webdal.env' file in the 'PrimeBase Setup' folder (in the 'goweb' folder) to set the timeout value. Changes take immediate effect.
  70.  
  71. Because opening a new session, and then opening a database can take quite a while (a few seconds), WebDAL can be configured to keep a certain number of new sessions ready. This number is also configurable in 'webdal.env'. 
  72.  
  73. Other parameters that may be set include:
  74.  
  75. Maximum Open Sessions - The maximum sessions that WebDAL will open.
  76. Idle Time Before Re-cycle - If the maximum number of sessions has been opened, WebDAL will try to re-cycle existing session. For this purpose WebDAL selects the least-recently used session. If this session is been idle for the specified time, then it is re-cycled. Set this value greater than Idle Time Before Closing to prevent re-cycling.
  77.  
  78.  
  79. Session Creation
  80.  
  81. WebDAL creates a session according to the default setup specified in the local 'connect.def' (connection definition) file in the 'PrimeBase Setup' folder.  Double-click on the connect.def to edit using the ConnectionSetup program.
  82.  
  83. The default connection is the first connection in the list. The 'DEFAULT' button sets a connection to the default.
  84.  
  85. NOTE! that if no user name is specified for the server, then WebDAL, will NOT connect to the server.
  86.  
  87. However, the DAL interpreter can be useful, even without a connection to a particular server, as illustrated by the 'secureEG' example.
  88.  
  89. Currently, the name of the database selected in the in ConnectionSetup is not yet used by WebDAL. In the next version of WebDAL the name of the database selected in the setup will be available in a global variable called: $database.
  90.  
  91. Remember to provide a password in the setup, if necessary, or WebDAL will not be able to open a database.
  92.  
  93.  
  94. Startup Script
  95.  
  96. When a DAL session is created it automatically executes a "startup" script, called 'startup.dal', if found.
  97.  
  98. Note that is the file is not found, no error occurs.
  99.  
  100. Look for the 'startup.dal' file in the 'PrimeBase Setup' folder. The DAL session searches for the file, starting in the current working directory, and then proceeding to the Setup folder, and to the 'Scripts' folder inside the setup folder.
  101.  
  102. The startup script is very useful when used in conjunction with WebDAL, and may be used to declare and initialize global variable, and also to declare certain standard procedures used by your WebDAL site.
  103.  
  104. For example: check out the 'PrintTable' procedure in the goweb, telephone database example. This DAL procedure prints a HTML table given a DAL cursor.
  105.  
  106. You can select values from a table into a cursor, and print the result in the form of an HTML table, very easily using this procedure. For example:
  107.  
  108. <HTML>
  109.     <HEAD>
  110.         <TITLE>The Person Table</TITLE>
  111.     </HEAD>
  112.     <BODY>
  113.     <DAL>
  114.     select * from person into cursorx; printtable(cursorx);
  115.     </DAL>
  116.     </BODY>
  117. </HTML>
  118.  
  119.  
  120. Page Caching
  121.  
  122. WebDAL can cache the web pages it serves in order to speed access. Cached pages are 'pre-compiled', allowing for fast execution of the embedded DAL.
  123.  
  124. Turn caching off (set cache size to zero) when you are debugging or you may not see the most recent changes to the pages.
  125.  
  126.  
  127. Form Handling
  128.  
  129. Forms are extremely easy to handle in WebDAL because the form fields that are declared in the HTML page, are directly available as DAL variables. This means, however, that you must use valid DAL variable names for the form fields (i.e. must begin with a character, and may contain no spaces).
  130.  
  131. When a page is called up by a form, and before WebDAL executes the page, each form field is declared as a variable of type VARCHAR, and the field value is assigned to the variable. For example:
  132.  
  133. <HTML>
  134.     <HEAD>
  135.         <TITLE>Greetings from DAL</TITLE>
  136.     </HEAD>
  137.     <BODY>
  138.         <H2>What is your name?</H2>
  139.         <BR>
  140.         <FORM METHOD=POST  ACTION="WebDAL.acgi$hello.html">
  141.         <P><B>Name:</B> <INPUT TYPE=TEXT NAME="your_name" SIZE=24>
  142.         <INPUT TYPE=SUBMIT VALUE="OK">
  143.         </FORM>
  144.     </BODY>
  145. </HTML>
  146.  
  147. In the HTML above, a form field have been declared with the name 'your_name'. When the submit button (called 'OK') is clicked by the user, the browser requests the 'hello.html' page, and tells WebDAL, the names and values of the form fields.
  148.  
  149. WebDAL declares the variable 'your_name' before 'hello.html' as follows:
  150.  
  151. declare your_name = "<the value entered by the user>";
  152.  
  153. Inside the 'hello.html' page, you may refer to the field name as in this example:
  154.  
  155. <HTML>
  156.     <HEAD>
  157.         <TITLE>Greetings from DAL</TITLE>
  158.     </HEAD>
  159.     <BODY>
  160.     Hello <DAL> print your_name; </DAL> !
  161.     </BODY>
  162. </HTML>
  163.  
  164. If you want WebDAL to declare form variables elsewhere (not a the beginning of the page), you may use the FORM parameter, to the DAL tag. For example:
  165.  
  166. <DAL>
  167. declare varchar your_name = "somebody";
  168. </DAL>
  169. <HTML>
  170.     <HEAD>
  171.         <TITLE>Greetings from DAL</TITLE>
  172.     </HEAD>
  173.     <BODY>
  174.     Hello <DAL FORM> print your_name; </DAL> !
  175.     </BODY>
  176. </HTML>
  177.  
  178. When this page is requested by a form which declares the variable 'your_name', then WebDAL declares the variable 'your_name' just before the embedded DAL program with the FORM parameter. This overwrites the declaration performed at the top of the page, which also assigns the value 'somebody' to the variable 'your_name'.
  179.  
  180. The advantage of this setup is that if the page is not requested by a form (perhaps a bookmark has been set by the user to this page), then the variable 'your_name' is nevertheless declared, and contains a 'default' value.
  181.  
  182.  
  183. Security
  184.  
  185. WebDAL offers a high degree of security for your web site, mainly because the actual database access is performed on the server.
  186.  
  187. Users do not see any DAL that you place in the HTML pages and so gain no insight into how the database is accessed, or how you check user-names and passwords, etc. To this end, WebDAL can be instructed to retrieve pages from a particular directory which is not accessible by the Web Server itself. This makes it impossible for the browser user to by-pass WebDAL to retrieve the page. 
  188.  
  189. The location is called the 'HTML Page Location', and can be set using by double-click on the 'webdal.env' file.
  190.  
  191.  
  192. URL Re-direction
  193.  
  194. A useful feature of WebDAL is the ability to perform URL re-direction. The most common use is to jump to a particular page when an error is detected.
  195.  
  196. For example: an HTML form refers to a page, which contains an embedded DAL query based on the form variables. Before the query is executed, however you may wish to verify the input parameters. If an error is detected you can re-direct back to the form, or to a page, which contains an error message.
  197.  
  198. URL re-direction is performed by using the following DAL statement:
  199.  
  200. PRINT binary $null, "REDIRECT", "my-new-url";
  201.  
  202. binary $null indicates that a 'command' is about to follow. 
  203. REDIRECT is the name of the command to be performed by WebDAL.
  204. my-new-url is the URL to be directed to.
  205.  
  206. For an example of re-direction, try the 'secureEG' demo.
  207.  
  208.  
  209. Flow Control
  210.  
  211. Although it is generally contrary to the way the Web works, sometimes you wish to restrict the order in which Web pages are accessed. This is of particular use for programming, mazes or other games for a Web site.
  212.  
  213. You can do this using WebDAL quite easily. On any particular page, you may test the value of a global DAL variable maintained by WebDAL called '$lastpage'. The variable contains the name of the last page returned by WebDAL.
  214.  
  215. To ensure that a user takes a certain path through a number of pages, you simply need to check that the preceding pages is valid. For example:
  216.  
  217. <DAL>
  218. if ($lastpage != "hello.html" and $lastpage != "thispage.html")
  219.     print varbin $null, "REDIRECT", "WebDAL.acgi$"+$lastpage;
  220. </DAL>
  221.  
  222. <HTML>
  223.     <HEAD>
  224.         <TITLE>Restricted Flow</TITLE>
  225.     </HEAD>
  226.     <BODY >
  227.         This page can only be accessed from the 'html.hello page, and itself.
  228.     </BODY>
  229. </HTML>
  230.  
  231. This page checks the name of the last page, and if it is not one of the permitted preceding pages, it returns the user to the previous page!
  232.  
  233.  
  234. Lookout for our commercial version
  235.  
  236. The program you have downloaded is a demo version of WebDAL. The following major features are only available in the commercial version:
  237.  
  238. • Cross-platform capabilities. WebDAL runs on all platforms supported by PrimeBase.
  239. • Loading of pictures and other multi-media datatypes from the database.
  240. • ODBC back-end for access to database server other than PrimeBase.
  241.  
  242. Contact us, or check out our web-site for further information, pricing and availability of our first commercial release.
  243.  
  244. e-mail: info@snap.de
  245. www: http://www.snap.de/
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.